{% extends 'base.html' %}

{% block title %}
{% if user_type == 'student' %}
学生注册 - 机械臂实验系统
{% else %}
教师注册 - 机械臂实验系统
{% endif %}
{% endblock %}

{% block extra_css %}
<style>
    .register-container {
        max-width: 500px;
        margin: 30px auto;
        padding: 30px;
        border-radius: 10px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
        background-color: #fff;
    }
    
    .register-title {
        text-align: center;
        margin-bottom: 25px;
        color: #333;
    }
    
    .form-control {
        border-radius: 5px;
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .register-btn {
        width: 100%;
        padding: 12px;
        border-radius: 5px;
        margin-top: 10px;
    }
    
    .robot-icon {
        text-align: center;
        margin-bottom: 15px;
        font-size: 50px;
        color: #007bff;
    }
    
    .login-link {
        text-align: center;
        margin-top: 20px;
    }
    
    .help-text {
        font-size: 0.8rem;
        color: #6c757d;
        margin-top: -10px;
        margin-bottom: 15px;
    }
</style>
{% endblock %}

{% block content %}
<div class="register-container">
    <div class="robot-icon">
        <i class="bi bi-robot"></i>
    </div>
    <h2 class="register-title">
        {% if user_type == 'student' %}
        学生注册
        {% else %}
        教师注册
        {% endif %}
    </h2>
    
    <form method="post">
        {% csrf_token %}
        
        <div class="mb-3">
            {{ form.username }}
            {% if form.username.errors %}
                <div class="invalid-feedback d-block">
                    {{ form.username.errors }}
                </div>
            {% endif %}
        </div>
        
        <div class="mb-3">
            {% if user_type == 'student' %}
                {{ form.student_id }}
                {% if form.student_id.errors %}
                    <div class="invalid-feedback d-block">
                        {{ form.student_id.errors }}
                    </div>
                {% endif %}
            {% else %}
                {{ form.teacher_id }}
                {% if form.teacher_id.errors %}
                    <div class="invalid-feedback d-block">
                        {{ form.teacher_id.errors }}
                    </div>
                {% endif %}
            {% endif %}
        </div>
        
        <div class="mb-3">
            {{ form.email }}
            {% if form.email.errors %}
                <div class="invalid-feedback d-block">
                    {{ form.email.errors }}
                </div>
            {% endif %}
        </div>
        
        <div class="mb-3">
            {{ form.password1 }}
            {% if form.password1.errors %}
                <div class="invalid-feedback d-block">
                    {{ form.password1.errors }}
                </div>
            {% endif %}
            <div class="help-text">
                密码至少8个字符，不能全是数字，不能与个人信息相似。
            </div>
        </div>
        
        <div class="mb-3">
            {{ form.password2 }}
            {% if form.password2.errors %}
                <div class="invalid-feedback d-block">
                    {{ form.password2.errors }}
                </div>
            {% endif %}
        </div>
        
        {% if form.non_field_errors %}
            <div class="alert alert-danger">
                {% for error in form.non_field_errors %}
                    {{ error }}
                {% endfor %}
            </div>
        {% endif %}
        
        <button type="submit" class="btn btn-primary register-btn">注册</button>
    </form>
    
    <div class="login-link">
        已有账号？<a href="{% url 'login' %}" class="text-decoration-none">登录</a>
    </div>
</div>
{% endblock %} 